/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package slcu.model;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.BaseModel;
import com.liferay.portal.model.impl.BaseModelImpl;

import slcu.service.PersonalDelMinisterioLocalServiceUtil;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.util.HashMap;
import java.util.Map;

/**
 * @author tito
 */
public class PersonalDelMinisterioClp extends BaseModelImpl<PersonalDelMinisterio>
	implements PersonalDelMinisterio {
	public PersonalDelMinisterioClp() {
	}

	public Class<?> getModelClass() {
		return PersonalDelMinisterio.class;
	}

	public String getModelClassName() {
		return PersonalDelMinisterio.class.getName();
	}

	public long getPrimaryKey() {
		return _personalId;
	}

	public void setPrimaryKey(long primaryKey) {
		setPersonalId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_personalId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("personalId", getPersonalId());
		attributes.put("nombre", getNombre());
		attributes.put("mail", getMail());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long personalId = (Long)attributes.get("personalId");

		if (personalId != null) {
			setPersonalId(personalId);
		}

		String nombre = (String)attributes.get("nombre");

		if (nombre != null) {
			setNombre(nombre);
		}

		String mail = (String)attributes.get("mail");

		if (mail != null) {
			setMail(mail);
		}
	}

	public long getPersonalId() {
		return _personalId;
	}

	public void setPersonalId(long personalId) {
		_personalId = personalId;
	}

	public String getNombre() {
		return _nombre;
	}

	public void setNombre(String nombre) {
		_nombre = nombre;
	}

	public String getMail() {
		return _mail;
	}

	public void setMail(String mail) {
		_mail = mail;
	}

	public BaseModel<?> getPersonalDelMinisterioRemoteModel() {
		return _personalDelMinisterioRemoteModel;
	}

	public void setPersonalDelMinisterioRemoteModel(
		BaseModel<?> personalDelMinisterioRemoteModel) {
		_personalDelMinisterioRemoteModel = personalDelMinisterioRemoteModel;
	}

	public void persist() throws SystemException {
		if (this.isNew()) {
			PersonalDelMinisterioLocalServiceUtil.addPersonalDelMinisterio(this);
		}
		else {
			PersonalDelMinisterioLocalServiceUtil.updatePersonalDelMinisterio(this);
		}
	}

	@Override
	public PersonalDelMinisterio toEscapedModel() {
		return (PersonalDelMinisterio)Proxy.newProxyInstance(PersonalDelMinisterio.class.getClassLoader(),
			new Class[] { PersonalDelMinisterio.class },
			new AutoEscapeBeanHandler(this));
	}

	@Override
	public Object clone() {
		PersonalDelMinisterioClp clone = new PersonalDelMinisterioClp();

		clone.setPersonalId(getPersonalId());
		clone.setNombre(getNombre());
		clone.setMail(getMail());

		return clone;
	}

	public int compareTo(PersonalDelMinisterio personalDelMinisterio) {
		long primaryKey = personalDelMinisterio.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		PersonalDelMinisterioClp personalDelMinisterio = null;

		try {
			personalDelMinisterio = (PersonalDelMinisterioClp)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = personalDelMinisterio.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(7);

		sb.append("{personalId=");
		sb.append(getPersonalId());
		sb.append(", nombre=");
		sb.append(getNombre());
		sb.append(", mail=");
		sb.append(getMail());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(13);

		sb.append("<model><model-name>");
		sb.append("slcu.model.PersonalDelMinisterio");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>personalId</column-name><column-value><![CDATA[");
		sb.append(getPersonalId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>nombre</column-name><column-value><![CDATA[");
		sb.append(getNombre());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>mail</column-name><column-value><![CDATA[");
		sb.append(getMail());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _personalId;
	private String _nombre;
	private String _mail;
	private BaseModel<?> _personalDelMinisterioRemoteModel;
}